<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="班级" prop="className">
        <el-select v-model="queryParams.className" filterable clearable placeholder="请选择班级">
          <el-option
            v-for="item in classList"
            :key="item.id"
            :label="item.label"
            :value="item.id"
            size="small">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="classCircleList">
<!--      <el-table-column type="selection" width="55" align="center" />-->
      <el-table-column label="班级" align="center" prop="title" />
      <el-table-column label="动态标题" align="center" prop="courseName" />
      <el-table-column label="点赞数" align="center" prop="className" />
      <el-table-column label="评论数" align="center" prop="code" />
<!--      <el-table-column label="教师姓名" align="center" prop="name" />-->
<!--      <el-table-column label="学校代码" align="center" prop="schoolCode" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleView(scope.row)"
          >查看</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 查看对话框 -->
    <el-dialog  :close-on-click-modal="false" :title="title" :visible.sync="open" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="班级" prop="className">
          {{form.className}}
<!--          <el-input v-model="form.className" type="text"/>-->
        </el-form-item>
        <el-form-item label="动态内容" prop="content">
          {{form.content}}
<!--          <el-input v-model="form.content" type="textarea"/>-->
        </el-form-item>
        <el-form-item label="点赞数" prop="courseId">
          {{form.courseId}}
<!--          <el-input v-model="form.courseId" type="text"/>-->
        </el-form-item>
        <el-form-item label="班级照片" prop="code" class="imgbox">
          <div v-for="(item, index) in imglist" class="imgshow">
              <el-image
                        style="width:100%;height:100%;"
                        :src="item"
                        lazy
                        :preview-src-list="[item]">
              </el-image>
            <i class="el-icon-delete delico"></i>
<!--            <span class="shade"></span>-->
          </div>
        </el-form-item>
        <el-form-item label="评论列表" prop="courseId">
          {{form.courseId}}
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="cancel">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>


import { selectClazz } from '@/api/base/clazz'
import { listTeachPlangarden } from '@/api/teach/teachPlan'

export default {
  name: "gzt",
  data() {
    return {
      classList:[],//班级列表
      queryParams:{
        pageNum: 1,
        pageSize: 10,
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      classCircleList:[],
      // 表单参数
      form: {},
      // 表单校验
      rules: {

      },
      open:false,
      title:'查看班级圈',
      imglist:['http://192.168.101.17:21019/kids/banner.jpg','http://192.168.101.17:21019/kids/banner.jpg','http://192.168.101.17:21019/kids/banner.jpg','http://192.168.101.17:21019/kids/banner.jpg',]
    };
  },
  created() {
    this.getList()
    this.getclassList()
  },
  methods: {
    /**接口列表*/
    async getList(){
      try {
        this.loading = true;
        const data = await listTeachPlangarden(this.queryParams);
        this.classCircleList = data.rows;
        this.total = data.total;
        this.loading = false;
      }catch (e) {
        console.log(e)
      }
    },
    /**班级*/
    async getclassList(){
      try {
        const {rows}=await selectClazz();
        this.classList=rows.map(item=>{
          return {
            id:item.id,
            label:item.title,
          }
        })
      }catch (e) {
        console.log(e)
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /**查看*/
    handleView(row){
      this.form=row
      this.open=true
    },
    /**删除*/
    handleDelete(row){

    },
    // 取消按钮
    cancel() {
      this.open = false;
      // this.reset();
    },
  }
};
</script>
<style lang="scss" scoped>
.imgshow{
  position:relative;
  display: inline-block;
  margin: 0 10px 10px 0;
  width: 120px;
  height: 60px;
  float: left;
  //.shade{
  //  position: absolute;
  //  background: rgba(0,0,0,.5);
  //  left: 0;
  //  top: 0;
  //  z-index: 1;
  //  width: 100%;
  //  height: 100%;
  //  display: none;
  //}
  .delico{
    position: absolute;
    right: 10px;
    top: 5px;
    color: #fc0000;
    z-index: 2;
    display: none;
    cursor: pointer;
  }
}
.imgshow:hover{
  .delico{
    display: block;
  }
}

</style>
